<script src="<?php echo $this->basePath('js/plugins/jquery-print/jquery.jqprint-0.3.js'); ?>"></script>
<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right" id="dbshop-menu-top">
            <a href="<?php echo $this->url('sales', [], ['query' => $this->queryData]);?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回订单列表'); ?></a>
            <a href="javascript:;" onclick="print();" class="btn btn-primary btn-sm"><i class="fa fa-print"></i> <?php echo $this->translate('点击打印'); ?></a>
        </h1>
    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>
        <div class="row">
            <div class="col-md-12" id="print-order">
                <div class="box">
                    <div class="box-body">
                        <h2 class="page-header">
                            <?php echo $this->translate('订单号').'&nbsp;'.$this->orderInfo->getOrderSn(); ?>
                        </h2>

                        <div class="row">
                            <?php if($this->orderInfo->getDeliveryType() == 'delivery') { ?>
                                <div class="col-xs-6">
                                    <div class="table-responsive">
                                        <table class="table">
                                            <tbody>
                                            <tr>
                                                <td><?php echo $this->translate('配送配型'); ?>：<?php echo $this->salesHelper()->getDeliveryTypeName($this->orderInfo->getDeliveryType());  ?></td>
                                            </tr>
                                            <?php if($this->orderInfo->getDeliveryMode() == 2) { ?>
                                                <tr>
                                                    <td><?php echo $this->translate('快递信息'); ?>：<?php echo $this->translate('各商品拆分配送'); ?></td>
                                                </tr>
                                            <?php } else { ?>
                                                <tr>
                                                    <td><?php echo $this->translate('快递信息'); ?>：<?php echo $this->escapeHtml($this->orderInfo->getDeliveryName()); ?></td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo $this->translate('配送费用'); ?>：<?php echo $this->orderInfo->getCurrencySymbol() . $this->orderInfo->getShippingFee(); ?></td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo $this->translate('快递单号'); ?>：<?php echo $this->escapeHtml($this->orderInfo->getExpressNumber()); ?></td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="table-responsive">
                                        <table class="table">
                                            <tbody>
                                            <tr>
                                                <td><?php echo $this->translate('支付类型'); ?>：<?php echo $this->salesHelper()->getPaymentTypeName($this->orderInfo->getPaymentType()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('支付方式'); ?>：<?php echo $this->escapeHtml($this->orderInfo->getPaymentName()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('付款时间'); ?>：<?php echo $this->shopDateFormat()->orderTime($this->orderInfo->getPaymentFinishTime()); ?></td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="col-xs-12">
                                    <div class="table-responsive">
                                        <table class="table">
                                            <tbody>
                                            <tr>
                                                <td><?php echo $this->translate('收货人'); ?>：<?php echo $this->escapeHtml($this->deliveryAddress->getTrueName()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('电话号码'); ?>：<?php echo $this->adminHelper()->getAreaPhoneCode($this->deliveryAddress->getAreaCode()) .'&nbsp;'. $this->escapeHtml($this->deliveryAddress->getPhone()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('收货地址'); ?>：<?php echo $this->escapeHtml($this->deliveryAddress->getRegionValue().$this->deliveryAddress->getAddressInfo()); ?></td>
                                            </tr>
                                            <?php if(!empty($this->deliveryAddress->getPostCode())) { ?>
                                                <tr>
                                                    <td><?php echo $this->translate('邮政编码'); ?>：<?php echo $this->escapeHtml($this->deliveryAddress->getPostCode()); ?></td>
                                                </tr>
                                            <?php } ?>
                                            <?php if(!empty($this->deliveryAddress->getDeliveryTimeInfo())) { ?>
                                                <tr>
                                                    <td><?php echo $this->translate('送货时间'); ?>：<?php echo $this->escapeHtml($this->deliveryAddress->getDeliveryTimeInfo()); ?></td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            <?php } ?>
                            <?php if($this->orderInfo->getDeliveryType() == 'selfFetch') { ?>
                                <div class="col-xs-12">
                                    <p class="lead"><?php echo $this->translate('自提点信息'); ?></p>
                                    <div class="table-responsive">
                                        <table class="table">
                                            <tbody>
                                            <tr>
                                                <td><?php echo $this->translate('自提点名称'); ?>：<?php echo $this->escapeHtml($this->orderSelfLocation->getLocationName()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('自提点地址'); ?>：<?php echo $this->escapeHtml($this->orderSelfLocation->getRegionInfo() . $this->orderSelfLocation->getLocationAddress()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('联系人'); ?>：<?php echo $this->escapeHtml($this->orderSelfLocation->getLocationUser()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('联系电话'); ?>：<?php echo $this->escapeHtml($this->orderSelfLocation->getLocationPhone()); ?></td>
                                            </tr>
                                            <tr>
                                                <td><?php echo $this->translate('营业时间'); ?>：<?php echo $this->escapeHtml($this->orderSelfLocation->getLocationBusinessHours()); ?></td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                        <div class="table-responsive">
                            <table class="table shop-table table-bordered">
                                <thead>
                                <tr class="shop-bg-thead">
                                    <th><?php echo $this->translate('图片'); ?></th>
                                    <th width="32%"><?php echo $this->translate('商品名称'); ?></th>
                                    <th width="15%"><?php echo $this->translate('货号'); ?></th>
                                    <th width="15%"><?php echo $this->translate('规格'); ?></th>
                                    <th width="10%"><?php echo $this->translate('数量'); ?></th>
                                    <th width="10%"><?php echo $this->translate('单价'); ?></th>
                                    <th width="10%"><?php echo $this->translate('小计'); ?></th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach($this->orderInfo->getOrderGoods() as $goodsValue) { ?>
                                    <tr>
                                        <td><img src="<?php echo $this->goodsHelper()->goodsImage($goodsValue->getGoodsImage()); ?>" class="img-thumbnail"></td>
                                        <td>
                                            <?php if($goodsValue->getDeliveryId() > 0) { ?><small class="bg-primary" style="padding: 3px;border-radius:3px;"><?php echo $this->translate('快递信息').'：'.$this->escapeHtml($goodsValue->getDeliveryName()).'&nbsp;&nbsp;'.$this->translate('快递单号').'：'.$this->escapeHtml($goodsValue->getExpressNumber()); ?></small><?php } ?>
                                            <p style="margin-top: 5px;">
                                                <?php echo $this->escapeHtml($goodsValue->getGoodsName()); ?>
                                            </p>
                                        </td>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsItem()); ?></td>
                                        <td>
                                            <?php if(!empty($goodsValue->getInSpecGoodsStr())) { echo $this->escapeHtml($goodsValue->getInSpecGoodsStr()); } else echo $this->translate('无'); ?>
                                        </td>
                                        <td><?php echo $goodsValue->getBuyNum(); ?></td>
                                        <td><?php echo $this->orderInfo->getCurrencySymbol() . $goodsValue->getGoodsPrice(); ?></td>
                                        <td><?php echo $this->orderInfo->getCurrencySymbol() . $goodsValue->getGoodsAmount(); ?></td>
                                    </tr>
                                <?php } ?>

                                <?php if(!empty($this->integral) || !empty($this->orderInfo->getOrderMessage())) { ?>
                                    <tr>
                                        <td colspan="7" class="small">
                                            <?php if(!empty($this->orderInfo->getOrderMessage())) { ?>
                                                <div>
                                                    <strong><?php echo $this->translate('订单留言'); ?>：</strong>
                                                    <?php echo nl2br($this->escapeHtml($this->orderInfo->getOrderMessage())); ?>
                                                </div>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                                <tr>
                                    <td colspan="7" class="text-right">
                                        <?php echo $this->translate('商品总价'); ?>:<?php echo $this->orderInfo->getCurrencySymbol() . '&nbsp;' . $this->orderInfo->getGoodsAmount(); ?>
                                        + <?php echo $this->translate('配送费用'); ?>:<?php echo $this->orderInfo->getCurrencySymbol() . '&nbsp;' . $this->orderInfo->getShippingFee(); ?>
                                        <?php if ($this->orderDiscountRecord) foreach ($this->orderDiscountRecord as $recordValue) { ?>
                                        - <?php echo $recordValue->getDiscountInfo(); ?>:<?php echo $this->orderInfo->getCurrencySymbol() . '&nbsp;' . $recordValue->getDiscountCost(); ?>
                                        <?php } ?>
                                        <?php if($this->orderChangeAmountLog) foreach ($this->orderChangeAmountLog as $changeLog) { ?>
                                            <?php echo  $changeLog->getOrderChangeType() .'&nbsp;'. $this->translate('金额修改') .':'. $this->orderInfo->getCurrencySymbol() . $changeLog->getOrderChangeNum(); ?>
                                        <?php } ?>
                                        = <?php echo $this->translate('应付金额'); ?>:<?php echo $this->orderInfo->getCurrencySymbol() . $this->orderInfo->getOrderAmount(); ?>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </section>

</div>
<script language="javascript">
    function print(){
        $("#print-order").jqprint({
            debug: false,
            importCSS: true,
            printContainer: false,
            operaSupport: false
        });
    }
</script>